package com.jr.service.impl;

import com.jr.dao.SupplierwhitelistDao;
import com.jr.dao.impl.ISupplierWhitelistDaoImpl;
import com.jr.pojo.Enterprise;
import com.jr.pojo.Supplierwhitelist;
import com.jr.service.SupplierWhiteService;
import com.jr.util.PageHelper;
import com.jr.vo.WhiteEnter;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

public class ISupperWhiteServiceImpl implements SupplierWhiteService {
    SupplierwhitelistDao swd = new ISupplierWhitelistDaoImpl();
    @Override
    public ArrayList<WhiteEnter> queryWhite(WhiteEnter we, PageHelper ph,String myentername) {
        return swd.selectSupplierWhiteList(we,ph,myentername);
}
    @Override
    /*计算数据总条数*/
    public int queryWhiteCount(WhiteEnter we,String nowentername) {
        return swd.selectSupplierWhiteListCount(we,nowentername);
    }
    @Override
    /*根据当前的管理员所在的企业 获得 其他可添加企业名单*/
    /*返回的集合是所有可添加的企业的名称和id*/
    public Map<Integer, String> queryWhiteEnter(String entername) {
        return swd.selectWhiteEnterprise(entername);
    }

    @Override
    /*添加企业进入白名单*/
    public boolean addWhiteEnter(String nowendername, String addendername, String level, LocalDate date) {
        return swd.insertWhiteEnterByName(nowendername,addendername,level,date)>0;
    }


    /*添加进黑名单*/
    @Override
    public boolean addBlackEnter(Integer enterid, Integer whiteid, String resion, LocalDate date) {
        return swd.insertToBlackEnter(enterid,whiteid,resion,date)>0;
    }

    @Override
    /*从白名单中删除*/
    public boolean dropWhiteENter(Integer enterid, Integer whiteid) {
        return swd.delWhiteEnter(enterid,whiteid)>0;
    }

    @Override
    public boolean queryWhiteInBlack(Integer nowid, Integer blackid) {
        return swd.selectWhiteInBlack(nowid,blackid)>0;
    }


}